<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>阶层</title>
</head>

<body>
    <script>
        //求阶层
        var num = parseInt(prompt("请输入一个正整数："));
        var score = 1;
        for (var i = 1; i <= num; i++) { //控制行数
            score *= i;//等价于score=score*i;
        }
        alert(num + "的阶乘是：" + score);
        document.write(num + "的阶乘是：" + score);
    </script>
</body>

</html>